/**   
* @Title: UserMapper.java
* @Package com.an.nopro
* @Description: TODO(用一句话描述该文件做什么)
* @author antch,861710865@qq.com   
* @date 2017年8月6日 下午8:21:07
* @version V1.0   
*/


package com.an.nopro.mapper.test;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.an.nopro.entity.UserEntity;
import com.an.nopro.entity.UserSexEnum;

/**
* @ClassName: UserMapper
* @Description: TODO(Mapper与数据库映射)
* @author antch,861710865@qq.com
* @date 2017年8月6日 下午8:21:07
* 
*/

public interface UserMapper {

	@Select("Select * from users")
	@Results({@Result(property="userSex",column="userSex",javaType=UserSexEnum.class),
		@Result(property="nickName",column="mickName")})
	List<UserEntity> getAll();
	
	@Select("select * from users where id = #{id}")
	@Results({@Result(property="userSex",column="userSex",javaType=UserSexEnum.class),
		@Result(property="nickName",column="mickName")})
	UserEntity getOne(Long id);
	
	@Insert("Insert into users(userName,passWord,userSex) values(#{userName},#{passWord},#{userSex})")
	void insert(UserEntity userEntity);
	
	@Update("Update users set userName=#{userName},nickName=#{nickName} where id=#{id}")
	void update(UserEntity userEntity);
	
	@Delete("delete from users where id=#{id}")
	void delete(Long id);
}
